package com.hall.controller;

import com.hall.dao.BokeUserMapper;
import com.hall.pojo.common.Result;
import com.hall.service.BokeMeetService;
import com.hall.service.BokeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * boke项目接口
 */
@Controller
@RequestMapping("/boke")
public class BokeController {
    @Autowired
    private BokeUserService bokeUserService;
    @Autowired
    private BokeMeetService bokeMeetService;
    /**
     * 根据会议号获取参会者
     * @param id 会议id
     * @return 当前会议的参会专家
     */
    @ResponseBody
    @GetMapping("/user/meetUserList/{id}")
    public Result getUserBymeet(@PathVariable String id){
        return bokeUserService.selectAppUser(id);
    }

    /**
     * 获取当前会诊是否已上传病例文件
     * @param id 会议id
     * @return  病例文件id集合
     */
    @ResponseBody
    @GetMapping("/meet/caseUser/{id}")
    public Result<List<String>> selectCaseUser(@PathVariable  String id){
        List<String> list = bokeMeetService.selectCaseId(id);
        return CollectionUtils.isEmpty(list)?Result.error("不存在的会诊,或未上传病例"):Result.success(list,"请求成功");
    }

    /**
     * 查询用户在当前会诊的状态
     * @param meetId
     * @param userId
     * @return
     */
    @ResponseBody
    @GetMapping("/meet/isMeetUser/{meetId}/{userId}")
    public Result selectMeetUserRemarks(@PathVariable String meetId,@PathVariable String userId){
        int i = bokeUserService.selectMeetUserRemarks(meetId,userId);
        return i>0?Result.success("/bokehall/case/addCaseProposal?appointmentId=","请求成功"):Result.error("无权限添加病例描述");
    }

}
